#include<bits/stdc++.h>
using namespace std;


//求逆序对
long long  ret = 0;
int n = 0;
const int N = 1e6;
int arr[N], tmp[N];
//降序排列
void mergesort(int l,int r)  
{
	if (l >= r)return;
	int mid = (l + r) >> 1;
	mergesort(l,mid);
	mergesort(mid + 1, r);
	//到这里两边都是拍好的数据
	int i = l, j = mid + 1;
	int k = l;
	while (i <= mid && j <= r)
	{
		if (arr[i] <= arr[j])
		{
			tmp[k++] = arr[i++];
		}
		else//逆序对>
		{
			ret += mid - i + 1;//后面的都是逆序对    
			tmp[k++] = arr[j++];  
		}
	}
	while (i <= mid)tmp[k++] = arr[i++];  
	while (j <= r)tmp[k++] = arr[j++];   

	k = 0;
	//拷贝到原数组区间
	for (j = l; j <= r; j++)
		arr[j] = tmp[j];    
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i];  
	mergesort(0,n-1);
	cout << ret << endl;    
	return 0;
}